package com.treetao.union.web.shiro;

import org.apache.shiro.SecurityUtils;

import com.treetao.union.db.model.vo.ShiroUser;

/**
 * 系统用户
 */
public class MySysUser {
    /**
     * 取出Shiro中的当前用户LoginName.
     */
    public static String icon() {
    	ShiroUser user = getShiroUser();
        return user==null?null:user.getIcon();
    }

    public static Long id() {
    	ShiroUser user = getShiroUser();
        return user==null?null:user.getId();
    }

    public static String loginName() {
    	ShiroUser user = getShiroUser();
        return user==null?null:user.getloginName();
    }

    public static String nickName(){
    	ShiroUser user = getShiroUser();
        return user==null?null:user.getNickName();
    }

    public static ShiroUser getShiroUser() {
    	return (ShiroUser) SecurityUtils.getSubject().getPrincipal();
    }
}
